home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / aplictns / route_10 / part02 / pcbroute.c < prev    next >
C/C++ Source or Header  |  1990-04-23  |  4KB  |  119 lines

  1. /*
  2. ** printed circuit board autorouter, Copyright (C) Randy Nevin 1989.
  3. **
  4. ** you may give this software to anyone, make as many copies as you like, and
  5. ** post it on public computer bulletin boards and file servers. you may not
  6. ** sell it or charge any fee for distribution (except for media and postage),
  7. ** remove this comment or the copyright notice from the code, or claim that
  8. ** you wrote this code or anything derived from it. you may modify the code as
  9. ** much as you want (please document clearly with comments, and maintain the
  10. ** coding style), but programs which are derived from this one are subject to
  11. ** the conditions stated here. i am providing this code so that people can
  12. ** learn from it, so if you distribute it, please include source code, not
  13. ** just executables. contact me to report bugs or suggest enhancements; i do
  14. ** not guarantee support, but i will make an effort in good faith to help you,
  15. ** and i want to act as a central clearing house for future versions. you
  16. ** should contact me before undertaking a significant development effort, to
  17. ** avoid reinventing the wheel. if you come up with an enhancement you
  18. ** consider particularly useful, i would appreciate being informed so that it
  19. ** can be incorporated in future versions. my address is: Randy Nevin,
  20. ** 1731 211th PL NE, Redmond, WA 98053. this code is available directly from
  21. ** the author; just send a floppy and a self-addressed floppy mailer with
  22. ** sufficient postage.
  23. **
  24. ** HISTORY
  25. ** (name        date        description)
  26. ** ----------------------------------------------------
  27. ** randy nevin        2/1/89        initial version
  28. ** randy nevin        2/4/89        made retrace table driven, instead of
  29. **                    doubly-nested switch statements.
  30. ** randy nevin        2/4/89        changed dir from int to char (cut
  31. **                    storage for it in half).
  32. ** randy nevin        2/8/89        changed SetQueue and ReSetQueue to
  33. **                    give priority to goal nodes.
  34. ** randy nevin        2/11/89        don't output incremental search
  35. **                    results if stdout is redirected.
  36. ** randy nevin        2/11/89        released version 1.00
  37. ** udi finkelstein  2/27/90     amiga port, added single side switch.
  38. */
  39.  
  40. #include <stdio.h>
  41.  
  42. /*
  43. #ifndef M_XENIX
  44. #include <stdlib.h>
  45. #include <io.h>
  46. #endif
  47. */
  48.  
  49. #include <time.h>
  50. /*
  51. #include <string.h>
  52. */
  53.  
  54. extern char *strrchr();
  55.  
  56. #include "cell.h"
  57. /* #define ERR -1 if you want the original */
  58. #define ERR 10
  59.  
  60. /*
  61. ** if you run out of memory while routing large boards, there are two things
  62. ** you can do: (1) go into your config.sys file and disable everything you
  63. ** don't need. getting rid of things like ansi.sys, ramdisks, disk caches, and
  64. ** other terminate and stay resident (tsr) programs can free a lot of memory.
  65. ** (2) link the router, inspect the .map file, relink with the /CPARMAXALLOC:n
  66. ** switch, where n is calculated to allow for a near heap of about 5k. read
  67. ** the linker documentation before you do this. for me, the route.map file
  68. ** says the program needs 81EFh bytes. to this i add 1400h (5k) for a near
  69. ** heap to get 95EFh bytes or 95Fh paragraphs, which is 2399 decimal.
  70. */
  71.  
  72. int justboard = 0; /* need all data structures, not just the board */
  73. int one_side = 0; /* udi 27-2-90 single sided board flag */
  74.  
  75. extern void Initialize();
  76. extern void Solve();
  77. extern void Report();
  78.  
  79. void main ( argc, argv ) /* input board, route traces, output routed board */
  80. int argc;
  81. char *argv[];
  82. {
  83. char *self, *p;
  84. FILE *fin, *fout;
  85. long start, stop;
  86. int argcount=0;
  87.  
  88.     printf( "Copyright (C) Randy Nevin, 1989. Version 1.00\n" );
  89.     printf( "See source code for rights granted.\n\n" );
  90.     printf( "Amiga Port by Udi Finkelstein\n\n" );
  91.     start = time( NULL );
  92.     self = argv[argcount++];
  93.     /* get rid of initial part of path */
  94.     if ((p = strrchr( self, '/' )) || (p = strrchr( self, ':' )))
  95.         self = ++p;
  96.     if (argc < 3) { /* need infile and outfile */
  97.         printf( "usage: %s [-s] infile outfile\n", self );
  98.         exit( ERR );
  99.         }
  100.     if (strcmp(argv[argcount],"-s") == 0) {
  101.         one_side = 1;
  102.         argcount++;
  103.     } else one_side = 0;
  104.     if (!(fin = fopen( argv[argcount++], "r" ))) {
  105.         printf( "can't open %s\n", argv[1] );
  106.         exit( ERR );
  107.         }
  108.     if (!(fout = fopen( argv[argcount++], "w" ))) {
  109.         printf( "can't open %s\n", argv[2] );
  110.         exit( ERR );
  111.         }
  112.     Initialize( fin );
  113.     Solve();
  114.     Report( fout );
  115.     stop = time( NULL ) - start;
  116.     printf( "time = %ld second%s\n", stop, (stop == 1) ? "" : "s" );
  117.     exit( 0 );
  118. }
  119.